package xyz.labmem.base.core.tool

import org.springframework.util.ObjectUtils
import java.util.*

/**
 * @Author lty
 * @Date 2022/1/7 13:44
 * */

/**
 * 判断对象属性是否都为空
 */
fun Any.allFieldIsNULL(): Boolean {
    try {
        for (field in this::class.java.declaredFields) {
            field.isAccessible = true
            val objVal: Any? = field.get(this)
            if (!ObjectUtils.isEmpty(objVal)) {
                return false
            }
        }
    } catch (e: Exception) {
        e.printStackTrace()
        println("判断对象属性为空异常")
    }
    return true
}

fun Any.isnull(): Boolean = Objects.isNull(this)

fun Any.isNotNull(): Boolean {
    return isNull(this)
}

fun isNull(`object`: Any?): Boolean {
    return `object` == null
}